﻿namespace AB.ServiceDirectory.Dao
{
    using System.Collections.Generic;
    using System.Linq;
    using Entities;

    /// <summary>
    /// AContactTypeDao Class
    /// </summary>
    public sealed class AContactTypeDao
    {
        /// <summary>
        /// Prevents a default instance of the <see cref="AContactTypeDao"/> class from being created.
        /// </summary>
        private AContactTypeDao()
        {
        }

        private static readonly ServicesDirectoryDataContext Context = DB.Context;

        /// <summary>
        /// Finds the type of all contact.
        /// </summary>
        /// <returns>ContactType list</returns>
        public static ICollection<ContactType> FindAllContactType()
        {
            var dataContactType = from contactType in Context.ContactTypes select contactType;
            return dataContactType.ToList();
        }

        /// <summary>
        /// Finds the contact type by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns>ContactType object</returns>
        public static ContactType FindContactTypeById(int id)
        {
            var contact = Context.ContactTypes.FirstOrDefault(c => c.ContactTypeId == id);
            return contact;
        }
    }
}